Skip to content

Add helper for job metadata updates#1269

Open
peter941221 wants to merge 12 commits into
riverqueue:masterfrom
peter941221:peter/1218-set-metadata-helper
Open

Add helper for job metadata updates#1269
peter941221 wants to merge 12 commits into
riverqueue:masterfrom
peter941221:peter/1218-set-metadata-helper

Conversation

@peter941221
Copy link
Copy Markdown
Contributor

@peter941221 peter941221 commented Jun 2, 2026

  1. Adds a small public SetMetadata(ctx, key, value) helper for writing metadata updates onto the existing work-context merge path.
  2. Keeps the surface intentionally narrow: no batch API, no delete API, no hook signature changes, and no completion semantics changes.
  3. Rejects river:-prefixed keys so user code can't collide with River-reserved metadata keys.
  4. Adds focused coverage for the helper contract itself plus worker and HookWorkEnd integration paths.

Closes #1218.

Verification:

  1. go test ./... -run "TestSetMetadata|Test_Client_Common/(WithWorkerSettingMetadata|WithWorkEndHookSettingMetadata)" -count=1
  2. make test

@peter941221 peter941221 marked this pull request as ready for review June 2, 2026 03:59
Copy link
Copy Markdown
Contributor

@brandur brandur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Seems useful. I like the touch that we reject use of the river:* namespace.

Comment thread cmd/river/rivercli/river_cli_test.go Outdated
Comment thread worker.go
Comment thread client_test.go
Comment thread metadata.go Outdated
@peter941221
Copy link
Copy Markdown
Contributor Author

Thanks. I dropped the unrelated CLI and worker.go changes, scoped the test-only job args into the test case, and normalized the error message casing.

@peter941221
Copy link
Copy Markdown
Contributor Author

One note on the remaining red check: the retriggered run moved the failure from build_and_test (1.26, 15) to build_and_test (1.26, 14), and both failures happened during Docker pull for postgres:15 in container setup rather than during test execution, so this looks like CI flakiness rather than a code regression.\n\nLatest run: https://github.com/riverqueue/river/actions/runs/26804256615

Comment thread client_test.go
Comment thread metadata.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Official way to set keys in metadata

2 participants